package com.aca.entity;

import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.ToString;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import java.io.Serializable;

@ToString
@NoArgsConstructor
@AllArgsConstructor
@Entity
public class Admin implements Serializable {

    //注册成为普通管理员-注册时的用户名和密码
    private String username;
    private String pwd;

    //昵称
    private String nickname;

    //管理员权限号 1 最高权限管理员：可以对角色和场景增删改查
    //管理员权限号 0 普通权限管理员：只能看
    private int auth;


    @Id
    @Column(name = "username")
    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    @Basic
    @Column(name = "pwd")
    public String getPwd() {
        return pwd;
    }

    public void setPwd(String pwd) {
        this.pwd = pwd;
    }

    @Basic
    @Column(name = "nickname")
    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    @Basic
    @Column(name = "auth")
    public int getAuth() {
        return auth;
    }

    public void setAuth(int auth) {
        this.auth = auth;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Admin admin = (Admin) o;

        if (auth != admin.auth) return false;
        if (username != null ? !username.equals(admin.username) : admin.username != null) return false;
        if (pwd != null ? !pwd.equals(admin.pwd) : admin.pwd != null) return false;
        if (nickname != null ? !nickname.equals(admin.nickname) : admin.nickname != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = username != null ? username.hashCode() : 0;
        result = 31 * result + (pwd != null ? pwd.hashCode() : 0);
        result = 31 * result + (nickname != null ? nickname.hashCode() : 0);
        result = 31 * result + auth;
        return result;
    }
}
